<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport"
    content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  <meta name="apple-touch-fullscreen" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no">
  <meta name="x5-fullscreen" content="true">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />

  <!-- 标题及搜索关键字 -->
  <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  <meta name="description"
    content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS" />

  <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico">
  <title>军事标绘 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>


  <script type="text/javascript" src="../lib/include-lib.js" libpath="../lib/"
    include="jquery,font-awesome,bootstrap,bootstrap-checkbox,layer,haoutil,turf,mars3d,mars3d-widget"></script>

  <link href="css/style.css" rel="stylesheet" />
</head>

<body class="dark">
  <!--加载前进行操作提示，优化用户体验-->
  <div id="mask" class="signmask" onclick="removeMask()"></div>

  <div id="mars3dContainer" class="mars3d-container"></div>



  <div class="infoview">
    <div>
      图层状态：
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkShow" class="styled" type="checkbox" checked>
        <label for="chkShow">
          显示隐藏
        </label>
      </div>
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkPopup" class="styled" type="checkbox" checked>
        <label for="chkPopup">
          Popup绑定
        </label>
      </div>
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkTooltip" class="styled" type="checkbox">
        <label for="chkTooltip">
          Tooltip绑定
        </label>
      </div>
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkContextMenu" class="styled" type="checkbox" checked>
        <label for="chkContextMenu">
          右键菜单绑定
        </label>
      </div>

      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkHasEdit" class="styled" type="checkbox" checked>
        <label for="chkHasEdit">
          是否编辑
        </label>
      </div>
    </div>
    <div>
      图层管理：
      <input id="btnClear" type="button" class="btn btn-danger" value="清除" />
      <input id="btnExpFile" type="button" class="btn btn-primary" value="保存GeoJSON" title="保存为GeoJSON文件" />
      <input id="btnImpFile" type="button" class="btn btn-primary" value="打开GeoJSON" title="打开之前保存的GeoJSON文件" />

      <input id="input_draw_file" type="file" accept=".json" style="display:none;" />
    </div>

    <div>
      二维贴地：
      <input type="button" class="btn btn-primary" value="粗直箭头" onclick="drawPolygon('straightArrow')" />
      <input type="button" class="btn btn-primary" value="粗单尖直箭头" onclick="drawPolygon('fineArrow')" />
      <input type="button" class="btn btn-primary" value="燕尾直箭头" onclick="drawPolygon('fineArrowYW')" />
      <input type="button" class="btn btn-primary" value="攻击箭头" onclick="drawPolygon('attackArrow')" />
      <input type="button" class="btn btn-primary" value="平尾攻击箭头" onclick="drawPolygon('attackArrowPW')" />
      <input type="button" class="btn btn-primary" value="燕尾攻击箭头" onclick="drawPolygon('attackArrowYW')" />

      <input type="button" class="btn btn-primary" value="钳击箭头" onclick="drawPolygon('doubleArrow')" />
      <input type="button" class="btn btn-primary" value="闭合曲面" onclick="drawPolygon('closeVurve')" />
      <input type="button" class="btn btn-primary" value="集结地" onclick="drawPolygon('gatheringPlace')" />
    </div>

    <div>
      三维空间：
      <input type="button" class="btn btn-primary" value="粗直箭头" onclick="drawExtrudedPolygon('straightArrow')" />
      <input type="button" class="btn btn-primary" value="粗单尖直箭头" onclick="drawExtrudedPolygon('fineArrow')" />
      <input type="button" class="btn btn-primary" value="燕尾直箭头" onclick="drawExtrudedPolygon('fineArrowYW')" />
      <input type="button" class="btn btn-primary" value="攻击箭头" onclick="drawExtrudedPolygon('attackArrow')" />
      <input type="button" class="btn btn-primary" value="平尾攻击箭头" onclick="drawExtrudedPolygon('attackArrowPW')" />
      <input type="button" class="btn btn-primary" value="燕尾攻击箭头" onclick="drawExtrudedPolygon('attackArrowYW')" />

      <input type="button" class="btn btn-primary" value="钳击箭头" onclick="drawExtrudedPolygon('doubleArrow')" />
      <input type="button" class="btn btn-primary" value="闭合曲面" onclick="drawExtrudedPolygon('closeVurve')" />
      <input type="button" class="btn btn-primary" value="集结地" onclick="drawExtrudedPolygon('gatheringPlace')" />
    </div>
  </div>

  <!-- 切换视角到模型或地形（山区）的快捷按钮 -->
  <script type="text/javascript" src="js/center_terrain_3dtiles.js"></script>

  <!-- 图层管理相关处理js -->
  <script type="text/javascript" src="./js/graphicManager.js"></script>



  <script src="./js/common.js"></script>
  <script type="text/javascript">
    'use script' //开发环境建议开启严格模式

    let map
    let graphicLayer

    function initMap(options) {
      //合并属性参数，可覆盖config.json中的对应配置
      let mapOptions = mars3d.Util.merge(options, {
        scene: {
          center: { y: 31.516143, x: 117.282937, z: 46241.86, heading: 2.2, pitch: -48.7, roll: 0 },
        },
      })

      //创建三维地球场景
      map = new mars3d.Map('mars3dContainer', mapOptions)

      //创建矢量数据图层
      graphicLayer = new mars3d.layer.GraphicLayer({
        hasEdit: true,
        isAutoEditing: true, //绘制完成后是否自动激活编辑
      })
      map.addLayer(graphicLayer)

      //图层管理的相关处理，代码在\js\graphicManager.js
      initLayerManager(graphicLayer)

      //绑定标绘相关事件监听(可以自行加相关代码实现业务需求，此处主要做示例)
      graphicLayer.on(mars3d.EventType.drawStart, function (e) {
        console.log('开始绘制', e)
      })
      graphicLayer.on(mars3d.EventType.drawAddPoint, function (e) {
        console.log('绘制过程中增加了点', e)
      })
      graphicLayer.on(mars3d.EventType.drawRemovePoint, function (e) {
        console.log('绘制过程中删除了点', e)
      })

      graphicLayer.on(mars3d.EventType.drawCreated, function (e) {
        console.log('创建完成', e)
      })
      graphicLayer.on(mars3d.EventType.editStart, function (e) {
        console.log('开始编辑', e)

        startEditing(e.graphic)
      })
      graphicLayer.on(mars3d.EventType.editMovePoint, function (e) {
        console.log('编辑修改了点', e)
        startEditing(e.graphic)
      })
      graphicLayer.on(mars3d.EventType.editRemovePoint, function (e) {
        console.log('编辑删除了点', e)

        startEditing(e.graphic)
      })
      graphicLayer.on(mars3d.EventType.editStop, function (e) {
        console.log('停止编辑', e)

        stopEditing()
      })
      graphicLayer.on(mars3d.EventType.removeGraphic, function (e) {
        console.log('删除了对象', e)

        stopEditing()
      })
    }

    //绘制
    function drawPolygon(type) {
      graphicLayer.startDraw({
        type: type,
        edittype: 'polygon',
        style: {
          color: '#ff0000',
          opacity: 0.6,
          clampToGround: true,
        },
      })
    }

    //绘制(带高度)
    function drawExtrudedPolygon(type) {
      graphicLayer.startDraw({
        type: type,
        edittype: 'polygon',
        style: {
          color: '#ffd500',
          opacity: 0.4,
          diffHeight: 300,
        },
      })
    }
    //附加：激活属性编辑widget【非必需，可以注释该方法内部代码】
    var timeTik

    function startEditing(graphic) {
      if (!graphic) {
        return
      }
      clearTimeout(timeTik)

      var plotAttr = mars3d.widget.getClass('widgets/plotAttr/widget.js')
      if (plotAttr && plotAttr.isActivate) {
        plotAttr.startEditing(graphic, graphic.coordinates)
      } else {
        mars3d.widget.activate({
          map: map,
          uri: 'widgets/plotAttr/widget.js',
          name: '属性编辑',
          graphic: graphic,
          lonlats: graphic.coordinates,
        })
      }
    }

    function stopEditing() {
      timeTik = setTimeout(function () {
        mars3d.widget.disable('widgets/plotAttr/widget.js')
      }, 200)
    }
    //附加：激活属性编辑widget【非必需，可以注释该方法内部代码】
  </script>
</body>

</html>
